package cn.yunhe.back.service.impl;

import cn.yunhe.back.mapper.TUserMapper;
import cn.yunhe.entity.TUser;
import cn.yunhe.entity.TUserinfo;
import cn.yunhe.back.mapper.TUserinfoMapper;
import cn.yunhe.back.service.TUserinfoService;
import com.baomidou.mybatisplus.core.conditions.SharedString;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author 代码生成器(自动生成LF)
 * @since 2019-06-12
 */
@Service
public class TTUserinfoServiceImpl implements TUserinfoService {
    @Autowired
    private TUserinfoMapper tUserinfoMapper;

    @Autowired
    private TUserMapper tUserMapper;

    @Override
    public Page<TUserinfo> getUserInfoByPage(String pageNum, String pageSize, TUserinfo tUserinfo) {
        Page<TUserinfo> page = new Page<TUserinfo>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
        List<TUser> userList=tUserMapper.selectList(new QueryWrapper<TUser>().select("id"));
        List list=new ArrayList();
        for (TUser tUser:userList) {
            TUserinfo tUserinfo1=tUserinfoMapper.selectOne(new QueryWrapper<TUserinfo>().eq("uid",tUser.getId()));
            list.add(tUserinfo1);
        }
        System.out.println(list);
        return page;
    }

    @Override
    public int updateById(TUserinfo tUserinfo) {
        return tUserinfoMapper.updateById(tUserinfo);
    }

    @Override
    public int selectCount() {
        return tUserinfoMapper.selectCount(new QueryWrapper<TUserinfo>());
    }
}
